<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="rule.css" />
<title>Üye</title>
<script>
var tum_makale_listesi;
var profil_element_listesi;
var gelen_mesaj_listesi;
var konu_listesi;
var bilim_dali_listesi;
var dergi_listesi;
var dergi_sayi_listesi;
var sayi_makale_listesi;
var makale_yorum_listesi;
var uygun_basvuru_listesi;

window.onload=function sessionKontrolu(){
	var xmlhttp;
	
	if (window.XMLHttpRequest)  	
 		 xmlhttp=new XMLHttpRequest(); 	 
  
	else  	
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	
	xmlhttp.onreadystatechange=function()
	{  
  		if (xmlhttp.readyState==4 && xmlhttp.status==200){
  			if(xmlhttp.responseText == 'yetkisiz')
  			{
  				alert("Bu sayfaya giriş izniniz yoktur");
  				window.location.href="index.jsp";	
  			}
  			else{
  				profilGetir();
  			}
  			
  		}
  	}
	
	xmlhttp.open("GET","http://localhost:8080/yazgellab/uyesessionkontrol.action",true);
	xmlhttp.send(null);
}

function rolKontrolEt(rol_no){
	var xmlhttp;
	
	if (window.XMLHttpRequest)  	
 		 xmlhttp=new XMLHttpRequest(); 	 
  
	else  	
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	
  
	xmlhttp.onreadystatechange=function()
	{  
  		if (xmlhttp.readyState==4 && xmlhttp.status==200){
  			if(xmlhttp.responseText=="yazar"){
  				window.location.href="yazar.jsp";
  			}
  			else if(xmlhttp.responseText=="editor"){
  				window.location.href="editor.jsp";
  			}
			else if(xmlhttp.responseText=="hakem"){
				window.location.href="hakem.jsp";
  			}
			else{
				alert("Sistemde öyle bir rolünüz bulunmamaktadır");
			}
  		}   	
  			 
 	}
	
	xmlhttp.open("GET","http://localhost:8080/yazgellab/rolkontrolet.action?rol_no="+rol_no,true);
	xmlhttp.send(null);
}

function anasayfa(){
	profilGetir();
}

function profilGetir(){
	var xmlhttp;
	
	if (window.XMLHttpRequest)  	
 		 xmlhttp=new XMLHttpRequest(); 	 
  
	else  	
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	
  
	xmlhttp.onreadystatechange=function()
	{  
  		if (xmlhttp.readyState==4 && xmlhttp.status==200){
  			profil_element_listesi=xmlhttp.responseText.split("|");
  			document.getElementById('panel').innerHTML='<input type="button" value="Profil Duzenle" onclick="edit()"></input><input type="button" value="Silinme Başvurusu Yap" onclick="silinmeBasvurusuYap()"></input><input type="button" value="Rol Basvurusu Yap" onclick="secim()"></input><br>Ad	:<input id="ad" style="margin-left: 80px" type="text" name="ad" size="20" value="'+profil_element_listesi[0]+'" readonly><br>Soyad :<input id="soyad" style="margin-left: 60px" type="text" name="soyad" size="20" value="'+profil_element_listesi[1]+'" readonly><br>Doğum Yeri :<input id="dogum_yeri" style="margin-left: 25px" type="text" name="dogum_yeri" size="20" value="'+profil_element_listesi[2]+'" readonly><br>Doğum Tarihi :<input id="dogum_tarihi" style="margin-left: 17px" type="text" name="dogum_tarihi" size="20" value="'+profil_element_listesi[3]+'" readonly><br>Meslek :<input id="meslek" style="margin-left: 54px" type="text" name="meslek" size="20" value="'+profil_element_listesi[4]+'" readonly><br>Uzmanlık Alanı :<input id="uzmanlik_alani" style="margin-left: 8px" type="text" name="uzmanlik_alani" size="20" value="'+profil_element_listesi[5]+'" readonly><br>Unvan :<input id="unvan" style="margin-left: 60px" type="text" name="unvan" size="20" value="'+profil_element_listesi[6]+'" readonly><br>Öz Geçmiş :<textarea id="oz_gecmis" style="margin-left:32px;width:200px;height:100px" type="text" readonly>'+profil_element_listesi[7]+'</textarea><br>';
  		}   	
  			 
 	}
	
	xmlhttp.open("GET","http://localhost:8080/yazgellab/profilgetir.action",true);
	xmlhttp.send(null);
}

function edit() { 
	var dogum_tarihi_element=profil_element_listesi[3].split("-");
    document.getElementById("panel").innerHTML = '<table width="00%" border="0" cellspacing="1" cellpadding="0"> <tr><td>Ad*:</td><td class="data"><input type="text" name="ad" id="ad" value="'+profil_element_listesi[0]+'"></td></tr> <tr><td>Soyad*:</td><td class="data"><input type="text" name="soyad" id="soyad" value="'+profil_element_listesi[1]+'"></td></tr> <tr><td>Doğum Yeri*:</td><td class="data"><input type="text" name="dogum yeri" id="dogum_yeri" value="'+profil_element_listesi[2]+'"><tr><td>Doğum Tarihi*:</td><td class="data"><name="dogum tarihi" id="dogum_tarihi"> <select name="DateOfBirth_Day" id="dateofbirth_day"> <option> - Gün - </option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="DateOfBirth_Month"  id="dateofbirth_month"> <option> - Ay - </option> <option name="Ocak" value="01">Ocak</option> <option name="Subat" value="02">Şubat</option> <option name="Mart" value="03">Mart</option> <option name="Nisan" value="04">Nisan</option> <option name="Mayis" value="05">Mayıs</option> <option name="Haziran" value="06">Haziran</option> <option name="Temmuz" value="07">Temmuz</option> <option name="Agustos" value="08">Ağustos</option> <option name="Eylul" value="09">Eylül</option> <option name="Ekim" value="10">Ekim</option> <option name="Kasim" value="11">Kasım</option> <option name="Aralik" value="12">Aralık</option> </select> <select name="DateOfBirth_Year" id="dateofbirth_year"> <option> - Yıl - </option> <option value="2004">2004</option> <option value="2003">2003</option> <option value="2002">2002</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> <option value="1998">1998</option> <option value="1997">1997</option> <option value="1996">1996</option> <option value="1995">1995</option> <option value="1994">1994</option> <option value="1993">1993</option> <option value="1992">1992</option> <option value="1991">1991</option> <option value="1990">1990</option> <option value="1989">1989</option> <option value="1988">1988</option> <option value="1987">1987</option> <option value="1986">1986</option> <option value="1985">1985</option> <option value="1984">1984</option> <option value="1983">1983</option> <option value="1982">1982</option> <option value="1981">1981</option> <option value="1980">1980</option> <option value="1979">1979</option> <option value="1978">1978</option> <option value="1977">1977</option> <option value="1976">1976</option> <option value="1975">1975</option> <option value="1974">1974</option> <option value="1973">1973</option> <option value="1972">1972</option> <option value="1971">1971</option> <option value="1970">1970</option> <option value="1969">1969</option> <option value="1968">1968</option> <option value="1967">1967</option> <option value="1966">1966</option> <option value="1965">1965</option> <option value="1964">1964</option> <option value="1963">1963</option> <option value="1962">1962</option> <option value="1961">1961</option> <option value="1960">1960</option> <option value="1959">1959</option> <option value="1958">1958</option> <option value="1957">1957</option> <option value="1956">1956</option> <option value="1955">1955</option> <option value="1954">1954</option> <option value="1953">1953</option> <option value="1952">1952</option> <option value="1951">1951</option> <option value="1950">1950</option> <option value="1949">1949</option> <option value="1948">1948</option> <option value="1947">1947</option> <option value="1946">1946</option> <option value="1945">1945</option> <option value="1944">1944</option> <option value="1943">1943</option> <option value="1942">1942</option> <option value="1941">1941</option> <option value="1940">1940</option> <option value="1939">1939</option> <option value="1938">1938</option> <option value="1937">1937</option> <option value="1936">1936</option> <option value="1935">1935</option> <option value="1934">1934</option> <option value="1933">1933</option> <option value="1932">1932</option> <option value="1931">1931</option> <option value="1930">1930</option> <option value="1929">1929</option> <option value="1928">1928</option> <option value="1927">1927</option> <option value="1926">1926</option> <option value="1925">1925</option> <option value="1924">1924</option> <option value="1923">1923</option> <option value="1922">1922</option> <option value="1921">1921</option> <option value="1920">1920</option> <option value="1919">1919</option> <option value="1918">1918</option> <option value="1917">1917</option> <option value="1916">1916</option> <option value="1915">1915</option> <option value="1914">1914</option> <option value="1913">1913</option> <option value="1912">1912</option> <option value="1911">1911</option> <option value="1910">1910</option> <option value="1909">1909</option> <option value="1908">1908</option> <option value="1907">1907</option> <option value="1906">1906</option> <option value="1905">1905</option> <option value="1904">1904</option> <option value="1903">1903</option> <option value="1902">1902</option> <option value="1901">1901</option> <option value="1900">1900</option> </select> </td></tr> <tr><td>Meslek*:</td><td class="data"><input type="text" name="meslek" id="meslek" value="'+profil_element_listesi[4]+'"></td></tr> <tr><td>Uzmanlık Alanı:</td><td class="data"><input type="text" name="uzmanlik alani" id="uzmanlik_alani" value="'+profil_element_listesi[5]+'"></td></tr> <tr><td>Unvan:</td><td class="data"><input type="text" name="unvan" id="unvan" value="'+profil_element_listesi[6]+'"></td></tr><tr><td>Öz Geçmiş:</td><td method="post" action=""><textarea id="oz_gecmis" name="comments" cols="25" rows="5">'+profil_element_listesi[7]+'</textarea><br></td></tr> <td><tr> <input type="button" value="Duzenle" onclick="profilDuzenle()"></input> </td></tr></table>';
    document.getElementById("dateofbirth_day").selectedIndex=dogum_tarihi_element[2];
    document.getElementById("dateofbirth_month").selectedIndex=dogum_tarihi_element[1];
    document.getElementById("dateofbirth_year").selectedIndex=2004-dogum_tarihi_element[0]+1;
}

function profilDuzenle()
{
	var xmlhttp;
	
	if (window.XMLHttpRequest) 
		xmlhttp=new XMLHttpRequest(); 
	
	else 
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	
	
	xmlhttp.onreadystatechange=function()
	{ 
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			alert(xmlhttp.responseText);
			profilGetir();
		}
			
	}
	
	if(document.getElementById("ad").value=="" || document.getElementById("soyad").value=="" || document.getElementById("dogum_yeri").value=="" || document.getElementById("dateofbirth_day").value=="- Gün -" || document.getElementById("dateofbirth_month").value=="- Ay -" || document.getElementById("dateofbirth_year").value=="- Yıl -"){
		alert("Yıldızlı alanlar boş bırakılamaz");
	}
	else{
		var ad=document.getElementById("ad").value;
		var soyad=document.getElementById("soyad").value;
		var dogum_yeri=document.getElementById("dogum_yeri").value;
		
		var dogum_tarihi_gun=document.getElementById("dateofbirth_day").value;
		var dogum_tarihi_ay=document.getElementById("dateofbirth_month").value;
		var dogum_tarihi_yil=document.getElementById("dateofbirth_year").value;
		
		var dogum_tarihi=dogum_tarihi_yil+"-"+dogum_tarihi_ay+"-"+dogum_tarihi_gun;
		
		
		var meslek=document.getElementById("meslek").value;
		var uzmanlik_alani=document.getElementById("uzmanlik_alani").value;
		var unvan=document.getElementById("unvan").value;
		var oz_gecmis=document.getElementById("oz_gecmis").value;
		
		
		xmlhttp.open("GET","http://localhost:8080/yazgellab/profilduzenle.action?ad="+ad+"&soyad="+soyad+"&dogum_yeri="+dogum_yeri+"&meslek="+meslek+"&dogum_tarihi="+dogum_tarihi+"&uzmanlik_alani="+uzmanlik_alani+"&unvan="+unvan+"&oz_gecmis="+oz_gecmis,true);
		xmlhttp.send(null);
	}
}

function secim() { 
var xmlhttp;
	
	if (window.XMLHttpRequest)  	
 		 xmlhttp=new XMLHttpRequest(); 	 
  
	else  	
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	
	xmlhttp.onreadystatechange=function()
	{  
  		if (xmlhttp.readyState==4 && xmlhttp.status==200){
  			var code="";
  			var counter;
  			uygun_basvuru_listesi=xmlhttp.responseText.split("|");
  			if(uygun_basvuru_listesi.length!=1){
  				counter=uygun_basvuru_listesi.length-1;
  				code+='<table width="00%" border="0" cellspacing="1" cellpadding="0">  <tr><td>Rol İsteği</td><td class="data"><select id="rolselect" enabled>';
  				/*<option value="yazar">Yazar</option> <option value="hakem">Hakem</option> <option value="editor">Editör</option>*/
  				for(var i=0;i<counter;i++){
  					if(uygun_basvuru_listesi[i]=="1"){
  						code+='<option value="yazar">Yazar</option>';
  					}
  					else if(uygun_basvuru_listesi[i]=="2"){
  						code+='<option value="editor">Editör</option>';
  					}
  					else if(uygun_basvuru_listesi[i]=="3"){
  						code+='<option value="hakem">Hakem</option>';
  					}
  				}
  				code+='</td></tr> <td><tr> <input type="button" value="Rol Başvurusu Yap" onclick="rolBasvurusuYap()"></input> </td></tr></table>';
  				
  			}
  			else{
	  			code += '<p style="margin-top:30px">Bütün rollerde zaten aktifsiniz yada henüz cevaplanmamış başvurularınız bulunmakta..</p>';
  			}
  			document.getElementById("panel").innerHTML=code;
  		}
  	}
	
	xmlhttp.open("GET","http://localhost:8080/yazgellab/basvuruyauygunrol.action",true);
	xmlhttp.send(null);
	
	
}

function cikisYap(){
	var xmlhttp;
	
	if (window.XMLHttpRequest)  	
 		 xmlhttp=new XMLHttpRequest(); 	 
  
	else  	
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	
	xmlhttp.onreadystatechange=function()
	{  
  		if (xmlhttp.readyState==4 && xmlhttp.status==200){
  			if(xmlhttp.responseText == 'basarili_cikis')
  			{
  				window.location.href="index.jsp";		
  			}
  			
  		}
  	}
	
	xmlhttp.open("GET","http://localhost:8080/yazgellab/cikisYap.action?cikis_tipi=0",true);
	xmlhttp.send(null);
}

function listele() {
	
	var xmlhttp;

	if (window.XMLHttpRequest) 
		xmlhttp=new XMLHttpRequest(); 

	else 
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");


	xmlhttp.onreadystatechange=function()
	{ 
	if (xmlhttp.readyState==4 && xmlhttp.status==200){
		var code="";
		var counter;
		tum_makale_listesi=xmlhttp.responseText.split("|");
		if(tum_makale_listesi.length!=1){
			counter=(tum_makale_listesi.length-1)/5;
	
			code+='<table border="1" style="margin-top:30px">';
			code+='<tr><td><b>Başlık</b></td><td><b>Yayınlanma Yılı</b></td><td><b>Yazar</b></td><td>Makale Aç</td></tr>';
			for(var i=0;i<counter;i++){
				
				code+='<tr><td>'+tum_makale_listesi[i*5+1]+'</td><td>'+tum_makale_listesi[i*5+3]+'</td><td>'+tum_makale_listesi[i*5+4]+'</td><td><button type="button" onClick="makaleAc(\''+tum_makale_listesi[i*5+2]+'\','+tum_makale_listesi[i*5]+')">Makale Aç</button> </td></tr>';
	
			}
			code+="</table><br>";
		}
		else{
			code+='<p>Sisteme kayıtlı herhangi bir makale bulunmamaktadır</p>';
		}
	
		document.getElementById("panel").innerHTML=code;
		}
	}
	xmlhttp.open("GET","http://localhost:8080/yazgellab/listele.action",false);
	xmlhttp.send(null);	
}

function silinmeBasvurusuYap()
{
	var xmlhttp;
	
	if (window.XMLHttpRequest) 
		xmlhttp=new XMLHttpRequest(); 
	
	else 
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	
	
	xmlhttp.onreadystatechange=function()
	{ 
		if (xmlhttp.readyState==4 && xmlhttp.status==200) 
			document.getElementById("myDiv").innerHTML=xmlhttp.responseText; 
	}
	
	
	xmlhttp.open("GET","http://localhost:8080/yazgellab/silinmebasvurusuyap.action",true);
	xmlhttp.send(null);
	
	alert("Silinme başvurunuz başarıyla sistem yöneticimize iletilmiştir.");
}

function rolBasvurusuYap()
{
	var xmlhttp;
	
	if (window.XMLHttpRequest) 
		xmlhttp=new XMLHttpRequest(); 
	
	else 
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	
	
	xmlhttp.onreadystatechange=function()
	{ 
		if (xmlhttp.readyState==4 && xmlhttp.status==200) 
			document.getElementById("myDiv").innerHTML=xmlhttp.responseText; 
	}
	
	
	var rol_secimi=document.getElementById("rolselect").value;
	
	
	xmlhttp.open("GET","http://localhost:8080/yazgellab/rolbasvurusuyap.action?rol_secimi="+rol_secimi,true);
	xmlhttp.send(null);
	
	alert("Rol başvurunuz başarıyla sistem yöneticimize iletilmiştir.");
}


function gelenMesajlarSplit(text){
	gelen_mesaj_listesi=text.split("|");
}

function makaleYorumSplit(text){
	makale_yorum_listesi=text.split("|");
}

function dergiSayiSplit(text){
	dergi_sayi_listesi=text.split("|");
}

function sayiMakaleSplit(text){
   sayi_makale_listesi=text.split("|");	
}

function ucListeyiBirbirindenAyir(text){
	var temp=text.split("<#>");
	konu_listesi=temp[0].split("|");
	bilim_dali_listesi=temp[1].split("|");
	dergi_listesi=temp[2].split("|");
}

function mesajOkundu(mesaj_pk,i){
	document.getElementById('mesaj_okundu_butonu'+i).src="resources/okundu.png";
	
	var xmlhttp;
	
	if (window.XMLHttpRequest)  	
 		 xmlhttp=new XMLHttpRequest(); 	 
  
	else  	
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	
	xmlhttp.open("GET","http://localhost:8080/yazgellab/mesajokundu.action?mesaj_pk="+mesaj_pk,true);
	xmlhttp.send(null);
}

function gelenKutusu(){
	var xmlhttp;
	
	if (window.XMLHttpRequest)  	
 		 xmlhttp=new XMLHttpRequest(); 	 
  
	else  	
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

	xmlhttp.onreadystatechange=function()
	{  
  		if (xmlhttp.readyState==4 && xmlhttp.status==200){
  			
  			var code="";
  			var counter;
  			gelenMesajlarSplit(xmlhttp.responseText);
  			if(gelen_mesaj_listesi.length!=1){
				counter=(gelen_mesaj_listesi.length)/4;
  				
  				code+='<table border="1" style="margin-top:30px">';
  				code+='<tr><td><b>Okundu mu?</b></td><td><b>Mesaj</b></td></tr>';
  				var temp;
  				for(var i=0;i<counter;i++){
  					
  					if(gelen_mesaj_listesi[i*4+2]==0){
  						temp='<img id="mesaj_okundu_butonu'+i+'" src="resources/okunmadi.png" style="cursor:pointer" onClick="mesajOkundu('+gelen_mesaj_listesi[i*4]+','+i+')"/>';
  					}
  					else{
  						temp='<img src="resources/okundu.png"/>';
  					}
  					code+='<tr><td>'+temp+'</td><td>'+gelen_mesaj_listesi[i*4+3]+'</td></tr>';
  					
  				}
  				code+="</table><br>";
  			}
  			else{
  				code+='<p>Herhangi bir mesajınız bulunmamaktadır</p>';
  			}
 			
  			document.getElementById("panel").innerHTML=code;
  		}   	
  		
 	}
	
	xmlhttp.open("GET","http://localhost:8080/yazgellab/gelenmsjlistele.action",true);
	xmlhttp.send(null);
}

function sayiMakaleListele(sayi_pk,i){
	var xmlhttp;
		
		if (window.XMLHttpRequest)  	
	 		 xmlhttp=new XMLHttpRequest(); 	 
	  
		else  	
	  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200){
				var code="";
	  			var counter;
	  			sayiMakaleSplit(xmlhttp.responseText);
	  			code+='<select id="sayi_makale_listesi'+i+'">';
	  			if(sayi_makale_listesi.length!=1){
	  				counter=(sayi_makale_listesi.length-1)/3;
					for(var j=0;j<counter;j++){
	  					code+='<option value="'+sayi_makale_listesi[j*3+2]+'">'+sayi_makale_listesi[j*3+1]+'</option>';
	  				}
	  			}
	  			code+='</select>';
	  			document.getElementById("makale_ac_butonu"+i).disabled=false;
	  			document.getElementById("makale_listele_alani"+i).innerHTML=code;
			}
		}
		
		xmlhttp.open("GET","http://localhost:8080/yazgellab/sayimakalelistele.action?sayi_pk="+sayi_pk,true);
		xmlhttp.send(null);
	}
	
function dergiSayiGoster(dergi_pk,i){
	var xmlhttp;
	
	if (window.XMLHttpRequest)  	
 		 xmlhttp=new XMLHttpRequest(); 	 
  
	else  	
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			var code="";
  			var counter;
  			dergiSayiSplit(xmlhttp.responseText);
  			code+='<select id="sayi_select_listesi'+i+'" onChange="sayiMakaleListele(this.value,'+i+')" >';
  			if(dergi_sayi_listesi.length!=1){
  				counter=(dergi_sayi_listesi.length-1)/3;
				for(var j=0;j<counter;j++){
  					code+='<option value="'+dergi_sayi_listesi[j*3]+'">'+dergi_sayi_listesi[j*3+1]+'</option>';
  				}
  			}
  			code+='</select>';
  			document.getElementById("sayi_goster_alani"+i).innerHTML=code;
  			sayiMakaleListele(document.getElementById("sayi_select_listesi"+i).value,i);
  			
		}
	}
	
	xmlhttp.open("GET","http://localhost:8080/yazgellab/dergisayilistele.action?dergi_pk="+dergi_pk,true);
	xmlhttp.send(null);
}

function makaleAc(makale_yolu,makale_pk){
	
	var xmlhttp;
	
	if (window.XMLHttpRequest)  	
 		 xmlhttp=new XMLHttpRequest(); 	 
  
	else  	
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			var code="";
			var counter;
			makaleYorumSplit(xmlhttp.responseText);
			code+='<div style="margin-top:30px;width:900px;heigth:500px"><iframe src="'+makale_yolu+'" id="makale_iframe" style="width:600px;height:450px"></iframe><div id="yorum_divi" style="width:200px;height:450px;float:left;overflow:auto;overflow-x:hidden">';
			if(makale_yorum_listesi.length!=1){
				counter=(makale_yorum_listesi.length-1)/3;
				for(var j=0;j<counter;j++){
					code+=makale_yorum_listesi[j*3]+'<br><b>'+makale_yorum_listesi[j*3+2]+'</b><br><b>'+makale_yorum_listesi[j*3+1]+'</b><hr>';
				}
			}
			else{
				code+='İlk yorum yapan siz olun...';
			}
			code+='</div></div><br><div  style="margin-left:200px"><b>Yorum Yap</b><br><textarea id="yorum_kutusu" style="width:400px;height:100px"></textarea><br><button type="button" onClick="makaleyeYorumYap('+makale_pk+')">Yorum Yap</button></div> ';
			
			document.getElementById("panel").innerHTML=code;
		}
	}
	
	xmlhttp.open("GET","http://localhost:8080/yazgellab/makaleyorumgetir.action?makale_pk="+makale_pk,true);
	xmlhttp.send(null);
	
}

function yorumDiviYenile(makale_pk){
	var xmlhttp;
	
	if (window.XMLHttpRequest)  	
 		 xmlhttp=new XMLHttpRequest(); 	 
  
	else  	
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			var code="";
			var counter;
			makaleYorumSplit(xmlhttp.responseText);
			if(makale_yorum_listesi.length!=1){
				counter=(makale_yorum_listesi.length-1)/3;
				for(var j=0;j<counter;j++){
					code+=makale_yorum_listesi[j*3]+'<br><b>'+makale_yorum_listesi[j*3+2]+'</b><br><b>'+makale_yorum_listesi[j*3+1]+'</b><hr>';
				}
			}
			else{
				code+='İlk yorum yapan siz olun...';
			}
			
			document.getElementById("yorum_divi").innerHTML=code;
		}
	}
	
	xmlhttp.open("GET","http://localhost:8080/yazgellab/makaleyorumgetir.action?makale_pk="+makale_pk,true);
	xmlhttp.send(null);
}

function makaleyeYorumYap(makale_pk){
	
	if(document.getElementById('yorum_kutusu').value==""){
		alert("Boş yorum yollayamazsınız");
	}
	else{
		var xmlhttp;


		if (window.XMLHttpRequest) 
		xmlhttp=new XMLHttpRequest(); 

		else 
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");


		xmlhttp.onreadystatechange=function()
		{ 
			if (xmlhttp.readyState==4 && xmlhttp.status==200){
				yorumDiviYenile(makale_pk);
				document.getElementById('yorum_kutusu').value="";
			}
				
		}

		xmlhttp.open("GET","http://localhost:8080/yazgellab/yorumyap.action?makale_pk="+makale_pk+"&yorum="+document.getElementById('yorum_kutusu').value,true);
		xmlhttp.send(null);
	}
}

function tumDergiler(konu_pk,bilim_dali_pk){
	var xmlhttp;
	
	if (window.XMLHttpRequest)  	
 		 xmlhttp=new XMLHttpRequest(); 	 
  
	else  	
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

	xmlhttp.onreadystatechange=function()
	{  
  		if (xmlhttp.readyState==4 && xmlhttp.status==200){
  			var code="";
  			var counter;
  			ucListeyiBirbirindenAyir(xmlhttp.responseText);
  			code+='<select id="konu_listesi" style="margin-top:30px"><option value="-1">Tümü</option>';
  			if(konu_listesi.length!=1){
  				counter=(konu_listesi.length-1)/2;
				for(var i=0;i<counter;i++){
  					code+='<option value="'+konu_listesi[i*2]+'">'+konu_listesi[i*2+1]+'</option>';
  				}
  			}
  			code+='</select>';
  			
  			code+='<select id="bilim_dali_listesi" style="margin-top:30px;margin-left:20px"><option value="-1">Tümü</option>';
  			if(bilim_dali_listesi.length!=1){
  				counter=(bilim_dali_listesi.length-1)/2;
				for(var i=0;i<counter;i++){
  					code+='<option value="'+bilim_dali_listesi[i*2]+'">'+bilim_dali_listesi[i*2+1]+'</option>';
  				}
  			}
  			
  			code+='</select>';
  			
  			code+='<button style="margin-top:30px;margin-left:20px;" type="button" onClick="tumDergiler(document.getElementById(\'konu_listesi\').value,document.getElementById(\'bilim_dali_listesi\').value)">Listele</button>';
  			
			if(dergi_listesi.length!=1){
  				
				counter=(dergi_listesi.length-1)/4;
  				
  				code+='<br><table border="1" style="margin-top:10px">';
  				code+='<tr><td><b>Dergi İsmi</b></td><td><b>ISBN</b></td><td><b>Yayınlanmış Sayı</b></td><td><b>Sayı Listesi</b></td><td><b>Makale Listesi</b></td><td><b>Makaleyi Aç</b></td></tr>';
  				for(var i=0;i<counter;i++){
  					
  					code+='<tr><td>'+dergi_listesi[i*4+1]+'</td><td>'+dergi_listesi[i*4+2]+'</td><td>'+dergi_listesi[i*4+3]+'</td><td id="sayi_goster_alani'+i+'" >';
  					
  					if(dergi_listesi[i*4+3]=='0'){
  						code+='<button type="button" disabled>Sayı Listele</button>';
  					}
  					else{
  						code+='<button type="button" onClick="dergiSayiGoster('+dergi_listesi[i*4]+','+i+')">Sayı Listele</button>';
  					}
  					
  					code+='</td><td id="makale_listele_alani'+i+'" >Sayı Seçilmedi</td><td><button id="makale_ac_butonu'+i+'" type="button" onClick="makaleAc(document.getElementById(\'sayi_makale_listesi'+i+'\').value)" disabled>Makaleyi Aç</button></td></tr>';
  					
  					
  					
  				}
  				code+="</table><br>";
  			}
  			else{
  				code+='<br><p>Bu filtrelemede sisteme kayıtlı herhangi bir dergi bulunmamaktadır</p>';
  			}
  			document.getElementById("panel").innerHTML=code;
  		}   	
  		
 	}
	
	xmlhttp.open("GET","http://localhost:8080/yazgellab/tumdergilerilistele.action?konu_pk="+konu_pk+"&bilim_dali_pk="+bilim_dali_pk,true);
	xmlhttp.send(null);
}

</script>
</head>
<body>
<div id="maincontainer">
	<div id="maindiv1">
		<div id="banner"></div>
		<div id="login">
			<br><br><br><p>Başarıyla giriş yaptınız</p><br>
			<input type="button" value="Çıkış Yap" onclick="cikisYap()"></input>
		</div>
	</div>
	<div id="maindiv2">
		<div id="menu">
		<div id="navigation">
			<ul class="top-level">
        <li><a href="#" onClick="anasayfa()">ANASAYFA</a>
        </li>
        <li><a href="#" onClick="gelenKutusu()">GELEN KUTUSU</a></li>
        <li><a href="#" onClick="rolKontrolEt(1)">YAZAR PANELİM</a></li>
        <li><a href="#" onClick="rolKontrolEt(2)">EDİTÖR PANELİ</a></li>
        <li><a href="#" onClick="rolKontrolEt(3)">HAKEM PANELİM</a></li>
        <li><a href="#" onClick="tumDergiler(-1,-1)">TÜM DERGİLER</a>
        </li>
        <li><a href="#" onclick="listele()">TÜM MAKALELER</a>
        </li>
       
        <li><a href="#">ARAMA</a>
        </li>
    </ul>		
    </div>
		</div>
		<div id="panel">
			
			
		</div>
	</div>
	<div id="maindiv3">
		<div id="footer">
			<a href="" style="font-size:30;margin-top:55px;margin-left:65px;float:left;text-decoration: none">HAKKIMIZDA</a>
			<a href="" style="margin-left:65px;margin-top:55px;float:left;text-decoration: none">ILETISIM</a>
			<p style="margin-left:65px;float:left;margin-top:55px"> @DemirYayincilik2012 | Her hakki saklidir...</p>
		</div>
	</div>
</div>
</body>
</html>